<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/admin/include/init_admin.jsp" %>
<%@ page import="com.joinhawaii.admin.sales.*" %>
<%

	HashList code001	= CommonUtil.getCodeList("001");	//섬코드
	HashList code002	= CommonUtil.getCodeList("002");	//호텔구분
	HashList code119	= CommonUtil.getCodeList("119");	//견적구분
	HashList code120	= CommonUtil.getCodeList("120");	//견적의뢰상태

	HashList codeHotel	= CommonUtil.getCodeList("hotel", "전체");	//호텔
	HashList codeEnjoy	= CommonUtil.getCodeList("enjoy", "전체");	//선택관광
	HashList codeCar	= CommonUtil.getCodeList("106", "전체");	//렌터카

	String s_req_dt			= StringUtil.nvl(request.getParameter("s_req_dt"));
	String s_start_dt_from	= StringUtil.nvl(request.getParameter("s_start_dt_from"));
	String s_start_dt_to	= StringUtil.nvl(request.getParameter("s_start_dt_to"));
	String s_req_status		= StringUtil.nvl(request.getParameter("s_req_status"));
	String s_customer_name	= StringUtil.toHan(request.getParameter("s_customer_name"));
	String s_email_addr		= StringUtil.toHan(request.getParameter("s_email_addr"));
	String s_phone_no		= StringUtil.nvl(request.getParameter("s_phone_no"));
	String s_hotel_name		= StringUtil.nvl(request.getParameter("s_hotel_name"));
	String s_enjoy_name		= StringUtil.nvl(request.getParameter("s_enjoy_name"));
	String s_car_company	= StringUtil.nvl(request.getParameter("s_car_company"));

	String s_hotel_chk		= StringUtil.nvl(request.getParameter("s_hotel_chk"));
	String s_enjoy_chk		= StringUtil.nvl(request.getParameter("s_enjoy_chk"));
	String s_car_chk		= StringUtil.nvl(request.getParameter("s_car_chk"));

	String s_curr_page		= StringUtil.nvl(request.getParameter("s_curr_page"),"1");


	HashMap infos = new HashMap();
	infos.put("req_dt",			s_req_dt);
	infos.put("start_dt_from",		s_start_dt_from);
	infos.put("start_dt_to",		s_start_dt_to);
	infos.put("req_status",		s_req_status);
	infos.put("customer_name",	s_customer_name);
	infos.put("email_addr",		s_email_addr);
	infos.put("phone_no",		s_phone_no);
	infos.put("hotel_name",		s_hotel_name);
	infos.put("enjoy_name",		s_enjoy_name);
	infos.put("car_company",		s_car_company);
	infos.put("hotel_chk",		s_hotel_chk);
	infos.put("enjoy_chk",		s_enjoy_chk);
	infos.put("car_chk",		s_car_chk);
	
	infos.put("curr_page", 		s_curr_page);


	String where = "?1=1";
	if (!"".equals(s_req_dt))			where += "&s_req_dt=" + s_req_dt;
	if (!"".equals(s_start_dt_from))	where += "&s_start_dt_from=" + s_start_dt_from;
	if (!"".equals(s_start_dt_to))		where += "&s_start_dt_to=" + s_start_dt_to;
	if (!"".equals(s_req_status))		where += "&s_req_status=" + s_req_status;
	if (!"".equals(s_customer_name))	where += "&s_customer_name=" + s_customer_name;
	if (!"".equals(s_email_addr))		where += "&s_email_addr=" + s_email_addr;
	if (!"".equals(s_phone_no))			where += "&s_phone_no=" + s_phone_no;
	if (!"".equals(s_hotel_name))		where += "&s_hotel_name=" + s_hotel_name;
	if (!"".equals(s_enjoy_name))		where += "&s_enjoy_name=" + s_enjoy_name;
	if (!"".equals(s_car_company))		where += "&s_car_company=" + s_car_company;
	if (!"".equals(s_hotel_chk))		where += "&s_hotel_chk=" + s_hotel_chk;
	if (!"".equals(s_enjoy_chk))		where += "&s_enjoy_chk=" + s_enjoy_chk;
	if (!"".equals(s_car_chk))			where += "&s_car_chk=" + s_car_chk;


	SalesDAO dao 	= new SalesDAO();
	HashList list 	= dao.selectReqList(infos);

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>조인하와이</title>
	<%@ include file="/admin/include/cssnjs.jsp"  %>
	<script type="text/javascript">
	$(document).ready(function() {

		$('#s_customer_name').focus().select();

		$('#s_req_dt').mask('9999.99.99').datepicker();
		$('#s_start_dt_from').mask('9999.99.99').datepicker();
		$('#s_start_dt_to').mask('9999.99.99').datepicker();



		$('#list').find('tr').hover(
				function () { $(this).addClass("hover"); }
			  , function () { $(this).removeClass("hover"); }
			)
			.click(function(){
				$('#req_id').val($(this).attr('req_id'));
				$('#searchForm').attr('action', './reqDetail.jsp<%=where%>&job_type=U');
				$('#searchForm').submit();
			});
	});


	function fnNewReq() {
		$('#req_id').val('');
		$('#searchForm').attr('action', './reqDetail.jsp?job_type=C');
		$('#searchForm').submit();
	}


	function fnExcel() {
		$('#searchForm').attr('action', './reqExcel.jsp');
		$('#searchForm').submit();
		$('#searchForm').attr('action', './reqList.jsp');
	}

	</script>
</head>
<body>
<div id="wrap">
	<div id="top">
		<%@ include file="/admin/include/top.jsp" %>
	</div>
	<div id="page">
		<div id="menu">
			<%@ include file="/admin/include/leftMenu.jsp" %>
		</div>
		<div id="contents">
			<div class="menu_title">
				<h1>견적의뢰</h1>
				<p>관리자 > 견적관리 > <b>견적의뢰</b></p>
			</div>
			<div class="clear line_01"></div>

			<form id="searchForm" method="post" action="./reqList.jsp">
			<input type="hidden" name="req_id" id="req_id" value=""/>

			<table cellpadding="0" cellspacing="0" class="table_01 mt15">
			<colgroup>
				<col width="100px" />
				<col width="160px" />
				<col width="100px" />
				<col width="160px" />
				<col width="100px" />
				<col  />
			</colgroup>
			<tr>
			    <th><p>성명</p></th>
			    <td><input type="text" name="s_customer_name" id="s_customer_name" value="<%= s_customer_name %>" class="w120"/></td>
				<th><p>이메일</p></th>
				<td ><input type="text" name="s_email_addr" id="s_email_addr" value="<%= s_email_addr %>" class="w120"/></td>
				<th><p>연락처</p></th>
				<td class="brx"><input type="text" name="s_phone_no" id="s_phone_no" value="<%= s_phone_no %>" class="w120"/></td>
			</tr>
			<tr>
				<th><p>처리결과</p></th>
				<td>
					<select name="s_req_status" class="w120">
						<option value="">전체</option>
						<%= StringUtil.makeOption(code120, s_req_status) %>
					</select>
				</td>
			    <th><p>견적일자</p></th>
			    <td><input type="text" name="s_req_dt" id="s_req_dt" class="w90 c" value="<%= s_req_dt %>"/></td>
				<th><p>출발일자</p></th>
				<td class="brx">
					<input type="text" name="s_start_dt_from" id="s_start_dt_from" class="w90 c" value="<%= s_start_dt_from %>"/>
					~ <input type="text" name="s_start_dt_to" id="s_start_dt_to" class="w90 c" value="<%= s_start_dt_to %>"/>
				</td>
			</tr>
			<tr>
				<th><p>호텔명 <input type="checkbox" name="s_hotel_chk" value="Y" <%= StringUtil.checked("Y", s_hotel_chk) %>/></p></th>
				<td>
					<!--<input type="text" name="s_hotel_name" id="s_hotel_name" value="<%= s_hotel_name %>" class="w120"/>-->
					<select name="s_hotel_name" class="w120">
						<%= StringUtil.makeOption(codeHotel, s_hotel_name) %>
					</select>
				</td>
			    <th><p>선택관광 <input type="checkbox" name="s_enjoy_chk" value="Y" <%= StringUtil.checked("Y", s_enjoy_chk) %>/></p></th>
			    <td>
					<!--<input type="text" name="s_enjoy_name" id="s_enjoy_name" class="w120" value="<%= s_enjoy_name %>"/>-->
					<select name="s_enjoy_name" class="w120">
						<%= StringUtil.makeOption(codeEnjoy, s_enjoy_name) %>
					</select>
				</td>
				<th><p>렌터카 <input type="checkbox" name="s_car_chk" value="Y" <%= StringUtil.checked("Y", s_car_chk) %>/></p></th>
				<td class="brx">
					<select name="s_car_company" class="w120">
						<%= StringUtil.makeOption(codeCar, s_car_company) %>
					</select>
				</td>
			</tr>
			</table>

			<div class="mt10 mb10 r">
				<input type="image" class="button" src="/images/admin/btn_search.gif"/>
				<a href="#nohref" onclick="fnNewReq()"><img src="/images/admin/btn_request.gif"/></a>
				<a href="#nohref" onclick="fnExcel()"><img src="/images/admin/btn_excel.gif"/></a>
			</div>

			</form>

			<div class="search_result">검색결과 : <%= infos.get("total_count") %>건</div>

		    <table cellpadding="0" cellspacing="0" class="table_03">
				<colgroup>
					<col width="40px"/>
					<col width="80px"/>
					<col width="100px"/>
					<col width="100px"/>
					<col/>
					<col width="80px"/>
					<col width="180px"/>
					<col width="100px"/>
					<col width="90px"/>
				</colgroup>
				<thead>
					<tr>
						<th><p>No</p></th>
						<th><p>구분</p></th>
						<th><p>견적일자</p></th>
						<th><p>성명</p></th>
						<th><p>여행일정</p></th>
						<th><p>출발일자</p></th>
						<th><p>이메일</p></th>
						<th><p>연락처</p></th>
						<th><p>상태</p></th>
					</tr>
				</thead>
				<tbody id="list">
			<%	for (int i = 0; i < list.size(); i++) { %>
					<tr req_id="<%= list.get("req_id",i) %>">
						<td>
							<%=list.get("req_id",i) %>
						</td>
						<td><%= list.get("req_gubn_name", i) %></td>
						<td><%= StringUtil.toDate(list.get("req_dt", i)) %></td>
						<td><%= list.get("customer_name", i) %></td>
						<td class="l"><%= list.get("travel_type_name", i) %></td>
						<td><%= StringUtil.toDate(list.get("start_dt", i)) %></td>
						<td><%= list.get("email_addr", i) %></td>
						<td><%= list.get("phone_no", i) %></td>
						<td><%= list.get("req_status_name", i) %></td>
					</tr>
			<%	} %>
				</tbody>
			</table>

			<div class="paging">
				<%= StringUtil.getPageHtml(infos, "./reqList.jsp?"+where) %>
			</div>
		</div>
	</div>
</div>
</body>
</html>
